<template>
  <div class="ii-wrap">
    <div class="ii-wrap-left">
      <div class="ii-wrap-left-one" :class="walletIndex === 0 ? 'ii-line-active && ii-text-active && ii-bg-active': ''" @click="toggleIndex(0)">收入概述</div>
      <div class="ii-wrap-left-item">
        <!-- <img :class="(showItem && walletIndex === 1) ? 'img-animate' : '' " src="~assets/images/sel-arrow.png"> -->
        <p class="p1" :class="walletIndex === 1 ? 'ii-line-active && ii-bg-active': ''" @click="toggleIndex(1)">效果报表
           <i :class="(showItem && walletIndex === 1) ? 'icon-animate' : '' " class="icon iconxiala-copy"></i>
        </p>
        <transition name="fade-h">
          <div class="showColumn" v-show="(showItem && walletIndex === 1)">
            <p class="p2" :class="walletTwoIndex === 0 ? 'ii-text-active': ''" @click="toggleTwoIndex(1,0)">销售效果
            </p>
            <p class="p2 p3" :class="walletTwoIndex === 1 ? 'ii-text-active': ''" @click="toggleTwoIndex(1,1)">订单明细</p>
            <p class="p2 p3" :class="walletTwoIndex === 2? 'ii-text-active': ''" @click="toggleTwoIndex(1,2)">商品销量</p>
          </div>
        </transition>
      </div>
      <div class="ii-wrap-left-item">
        <!-- <img :class="(showItem && walletIndex === 2) ? 'img-animate' : '' " src="~assets/images/sel-arrow.png"> -->
        
        <p class="p1" :class="walletIndex === 2 ? 'ii-line-active && ii-bg-active': ''" @click="toggleIndex(2)">结算中心
          <i :class="(showItem && walletIndex === 2) ? 'icon-animate' : '' " class="icon iconxiala-copy"></i>
        </p>
        <transition name="fade">
          <div class="showColumn" v-show="(showItem && walletIndex === 2)">
            <p class="p2" :class="walletTwoIndex === 10 ? 'ii-text-active': ''" @click="toggleTwoIndex(2,10)">结算概览</p>
            <p class="p2 p3" :class="walletTwoIndex === 11 ? 'ii-text-active': ''" @click="toggleTwoIndex(2,11)">提现记录</p>
         </div>
        </transition>
      </div>
    </div>
    <div class="li-wrap-right">
      <nuxt-child/>
    </div>
  </div>
</template>
<script>
export default {
  async fetch({store}) {
    await store.commit('setInterIndex', 5) //导航commit的切换状态
  },
  layout: 'internalouts', 
  computed: { //vuex保留状态
    walletIndex() { //一级菜单
      return this.$store.state.walletIndex
    },
    walletTwoIndex() {
      return this.$store.state.walletTwoIndex
    }
  },
  beforeDestroy() {
    this.$store.commit('setWalletIndex', 0);
    this.$store.commit('setWalletTwoIndex', -1);
  },
  data() {
    return {
      index: 0, // 一级菜单
      changeIndex :0,
      selectIndex: 0, // 二级菜单
      showItem:false, //展示列表
    }
  },
  methods: {
    next (index) {
      this.flag = false;
    },
    // 新手指引 知道了
    stop () {
      this.flag = false;
    },
    toggleIndex(index) {
      if(index === 0){
        this.showItem = false;
        this.go('/wallet')
      } else if (index === 1) {
        if (this.walletIndex === 1) {
          this.showItem = !this.showItem;
        } else {
          this.showItem = true;
        }
      } else if (index === 2) {
        if (this.walletIndex === 2) {
          this.showItem = !this.showItem;
        } else {
          this.showItem = true
        }
      }
      this.$store.commit('setWalletIndex', index);
    },
    toggleTwoIndex(index, selectIndex) {
      this.$store.commit('setWalletTwoIndex', selectIndex);
      if(index === 0){
        this.showItem = false;
        this.go('/wallet')
      } else if (index === 1) {
        if (selectIndex === 0) {
          this.n = 5;
          this.flag = true;
          this.go('/wallet/saleEffects')
        } else if (selectIndex === 1) {
          this.n = 6;
          this.flag = true;
          this.go('/wallet/orderDetail')
        } else if (selectIndex === 2) {
          this.go('/wallet/shopSales')
        }
      } else if (index === 2) {
        if (selectIndex === 10) {
          this.go('/wallet/settleMent')
        } else if (selectIndex === 11) {
          this.go('/wallet/record')
        }
      }
    }
  }
}
</script>

<style scoped>
  .ii-wrap {
    display: flex;
    justify-content: space-between;
    min-width:1200px;
  }
  .ii-wrap-left {
    background: #efefef;
    width: 220px;
    border-radius: 4px;
    position: relative;
  }
  .li-wrap-right {
    flex:1;
    margin: 20px;
    min-width:940px;
  }
  .ii-wrap-left-one {
    height: 50px;
    border-bottom: 1px solid #f4f4f4;
    line-height: 50px;
    padding-left: 30px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    position: relative;
    user-select: none;
  }
  .ii-wrap-left-item {
    border-bottom: 1px solid #f4f4f4;
    user-select: none;
    position:relative;
    box-sizing:border-box;
  }
  .ii-wrap-left-item p {
    cursor: pointer;
  }
  .ii-wrap-left-item .icon {
    font-style: normal;
    font-size: 28px;
    position: absolute;
    top: 0px;
    right: 9px;
    z-index: 2;
    transition: all .5s;
    color: #777777;
  }
  .icon-animate{
    transform:rotate(-180deg);
  }
  .fade-enter,.fade-h-enter{
    max-height:0;
    opacity:0;
  }
  .fade-enter-to{
    max-height:68px;
    opacity:1;
  }
  .fade-h-enter-to{
    max-height:102px;
    opacity:1;
  }
  .fade-enter-active,.fade-h-enter-active{
    transition:all .5s;
  }
  .fade-leave{
    max-height:68px;
    opacity:1;
  }
  .fade-h-leave{
    max-height:102px;
    opacity:1
  }
  .fade-leave-to,.fade-h-leave-to{
    max-height:0px;
    opacity:0;
  }
  .fade-leave-active,.fade-h-leave-active{
    transition:all .5s;
  }
  .ii-wrap-left-item .p1 {
    font-size: 14px;
    color: #333;
    position: relative;
    height: 50px;
    line-height: 50px;
    padding-left: 30px;
    box-sizing:border-box;
  }
  .ii-wrap-left-item .p2 {
    font-size: 14px;
    color: #666;
    padding-left: 30px;
    margin-top:12px;
  }
  .ii-wrap-left-item .p3 {
   margin-top: 20px;
   margin-bottom: 20px;
  }
  .ii-wrap-left-last {
    height: 50px;
    line-height: 50px;
    padding-left: 30px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    position: relative;
    border-bottom: 1px solid #f4f4f4;
  }
  .ii-line-active::before {
    content: '';
    width: 3px;
    height: 26px;
    background: #0096e6;
    position: absolute;
    left: 0;
    top: 12px;
  }
  .ii-text-active {
    color: #0096e6 !important;
  }
  .ii-bg-active {
    width: 220px;
    height: 50px;
    background: #e6e6e6;
    box-sizing: border-box;
  }
</style>
